import { registerFilter } from 'amis'
import moment from 'moment'
import DateTimeColumn from '@/components/amis/SuperTable/column/DateTimeColumn'
import IndexColumn from '@/components/amis/SuperTable/column/IndexColumn'
import '@/components/Monaco/Monaco'

export { DateTimeColumn, IndexColumn }

class AmisInitialize {
	init = (): void => {
		this.registerDateTimeFilter()
	}

	registerDateTimeFilter = () => {
		registerFilter('datetime', (input, args): string => {
			try {
				return moment(input).format('YYYY-MM-DD HH:mm:ss')
			} catch {
				return 'invalid date'
			}
		})
	}
}

export default new AmisInitialize()
